package com.wc.算法提高课.C第三章_图论.欧拉回路和欧拉路径.骑马修栅栏;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.StringTokenizer;

/**
 * @Author congge
 * @Date 2024/10/22 11:13
 * @description https://www.acwing.com/problem/content/1126/
 */
public class Main {
    static FastReader sc = new FastReader();
    static PrintWriter out = new PrintWriter(System.out);
    static int N = 510, M = 2048;
    static int[][] g = new int[N][N];
    static int[] ans = new int[M];
    static int[] din = new int[N];
    static int m, cnt = 0;

    public static void main(String[] args) {
        m = sc.nextInt();
        while (m-- > 0) {
            int a = sc.nextInt(), b = sc.nextInt();
            g[a][b]++;
            g[b][a]++;
            din[b]++;
            din[a]++;
        }
        int start = 1;
        while (din[start] == 0) start++;
        for(int i = 1; i < N; i++){
            if (din[i] % 2 == 1){
                start = i;
                break;
            }
        }
        dfs(start);
        for (int i = cnt; i > 0; i--) out.println(ans[i]);
        out.flush();
    }

    static void dfs(int u) {
        for (int i = 1; i < N; i++) {
            if (g[u][i] == 0) continue;
            g[u][i]--;
            g[i][u]--;
            dfs(i);
        }
        ans[++cnt] = u;
    }
}

class FastReader {
    StringTokenizer st;
    BufferedReader br;

    FastReader() {
        br = new BufferedReader(new InputStreamReader(System.in));
    }

    String next() {
        while (st == null || !st.hasMoreElements()) {
            try {
                st = new StringTokenizer(br.readLine());
            } catch (IOException e) {
                e.printStackTrace();
            }
        }
        return st.nextToken();
    }

    int nextInt() {
        return Integer.parseInt(next());
    }

    String nextLine() {
        String s = "";
        try {
            s = br.readLine();
        } catch (IOException e) {
            e.printStackTrace();
        }
        return s;
    }

    long nextLong() {
        return Long.parseLong(next());
    }

    double nextDouble() {
        return Double.parseDouble(next());
    }

    // 是否由下一个
    boolean hasNext() {
        while (st == null || !st.hasMoreTokens()) {
            try {
                String line = br.readLine();
                if (line == null)
                    return false;
                st = new StringTokenizer(line);
            } catch (IOException e) {
                throw new RuntimeException(e);
            }
        }
        return true;
    }
}
